
import ShanbayUrl from './ShanbayUrl';
import config from '../../config';
export default class Shanbay {
    /**
     * 添加word
     * @param token token
     * @param word word
     */
    public static async addWord(token, word) {
        try {
            const url = new ShanbayUrl();
            const id = await url.GetWordId(token, word);
            await url.Post(token, id);
        } catch (e) {
            if (typeof e === "string") {
                return {
                    success: false,
                    msg: e,
                }
            } else {
                return {
                    success: false,
                    msg: e.message,
                    nologin: e.response.status === 401,
                    toomany: e.response.status === 429,
                }
            }
        }
        return {
            success: true,
        }
    }
    /**
     * 获取setting
     */
    public static async getSetting() {
        const url = new ShanbayUrl();
        return {
            success: true,
            data: {
                appkey: config.shanbay.appkey,
            }
        }
    }
}